<!--
 * Created by sf
 * 2019/11/11
 -->

<style scoped type="text/css">
  .tab-container {
    padding: 30px;
    background-color: #fff;
  }
</style>

<template>
  <div class="tab-container">
    <el-tabs v-model="id">
      <el-tab-pane
        v-for="tab in tabs"
        :key="tab.id"
        :name="tab.id.toString()"
        :label="tab.name">
        <keep-alive >
          <List :classify-id="tab.id"/>
        </keep-alive>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import commonMixin from '@/mixins/common'
import { PRODUCT_CONTENT_RELATIVE_URL_PREFIX } from '@/utils/constant'

import List from './list'

export default {
  mixins: [commonMixin],
  components: { List },
  props: {},
  data () {
    return {
      id: '0',
      tabs: []
    }
  },
  created () {
    this.getTabs()
  },
  watch: {
  },
  methods: {
    async getTabs () {
      let { data: res } = await this.$http.post(this.getApiUrl(PRODUCT_CONTENT_RELATIVE_URL_PREFIX + 'classify/get/all'), {})
      if (res.code === 200) {
        this.tabs = res.data
      }
    }
  }
}
</script>
